package com.szxy;

import com.szxy.service.OrderService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: zwz
 * @Date:2020/7/15 21:47
 * @Description:com.szxy
 * @Version:1.0
 **/
@SpringBootApplication
@EnableDiscoveryClient
@MapperScan("com.szxy.mapper")
@RestController
@EnableFeignClients
public class OrderServiceApplication {
    public static void main(String[] args) {
        SpringApplication.run(OrderServiceApplication.class, args);
    }

    @Autowired
    private OrderService orderService;

    /**
     * 下订单
     * @param userId  用户 ID
     * @param productId 商品号
     * @param count 商品数量
     * @return
     */
    @GetMapping("/addOrder/{userId}/{productId}/{count}")
    public ResponseEntity addOrder(
            @PathVariable String userId,
            @PathVariable String productId,
            @PathVariable Integer count) {
        this.orderService.addOrder(userId, productId, count);
        // 返回响应结果
        return ResponseEntity.ok().build();
    }
}
